import config from "@/config"
import http from "@/utils/request"

export default {
	api:{
		listByMenuId: {
			url: `${config.API_URL}/api/list/by/menu/`,
			name: "通过菜单获取接口",
			get: async function(menuId){
				return await http.get(this.url + menuId);
			}
		},
	},
	menu: {
		myMenus: {
			url: `${config.API_URL}/menu/my/list`,
			name: "获取我的菜单",
			get: async function(){
				return await http.get(this.url);
			}
		},
		myBtn: {
			url: `${config.API_URL}/menu/my/btn`,
			name: "获取我的按钮",
			get: async function(){
				return await http.get(this.url);
			}
		},
		myMenuIds: {
			url: `${config.API_URL}/menu/my/ids`,
			name: "获取我的菜单ID",
			get: async function(roleId){
				return await http.get(this.url+`/${roleId}`);
			}
		},
		create: {
			url: `${config.API_URL}/menu/create`,
			name: "创建菜单",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		batchDelete: {
			url: `${config.API_URL}/menu/batch/delete`,
			name: "菜单批量删除",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		update: {
			url: `${config.API_URL}/menu/update`,
			name: "更新菜单",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		list: {
			url: `${config.API_URL}/menu/list`,
			name: "获取菜单",
			get: async function(){
				return await http.get(this.url);
			}
		}
	},
	dic: {
		// tree: {
		// 	url: `${config.API_URL}/system/dic/tree`,
		// 	name: "获取字典树",
		// 	get: async function(){
		// 		return await http.get(this.url);
		// 	}
		// },
		list: {
			url: `${config.API_URL}/dic/list`,
			name: "字典列表",
			get: async function(params){
				return await http.get(this.url, params);
			}
		},
		itemList: {
			url: `${config.API_URL}/dic/item/list`,
			name: "字典列表",
			get: async function(params){
				return await http.get(this.url + `/${params.id}/${params.page}/${params.pageSize}`);
			}
		},
		get: {
			url: `${config.API_URL}/system/dic/get`,
			name: "获取字典数据",
			get: async function(params){
				return await http.get(this.url, params);
			}
		},
		create: {
			url: `${config.API_URL}/dic/create`,
			name: "创建字典",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		update: {
			url: `${config.API_URL}/dic/update`,
			name: "更新字典",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		delete: {
			url: `${config.API_URL}/dic/delete`,
			name: "删除字典",
			post: async function(id){
				return await http.post(this.url + `/${id}`);
			}
		},
		itemCreate: {
			url: `${config.API_URL}/dic/item/create`,
			name: "创建字典项",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		itemUpdate: {
			url: `${config.API_URL}/dic/item/update`,
			name: "更新字典项",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		itemDelete: {
			url: `${config.API_URL}/dic/item/delete`,
			name: "删除字典项",
			post: async function(id){
				return await http.post(this.url + `/${id}`);
			}
		},
	},
	role: {
		create: {
			url: `${config.API_URL}/role/create`,
			name: "创建角色",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		update: {
			url: `${config.API_URL}/role/update`,
			name: "更新角色",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		delete: {
			url: `${config.API_URL}/role/delete`,
			name: "删除角色",
			post: async function(id){
				return await http.post(this.url + `/${id}`);
			}
		},
		setPermissions: {
			url: `${config.API_URL}/role/set/permissions`,
			name: "设置角色权限",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		list: {
			url: `${config.API_URL}/role/list`,
			name: "获取角色列表",
			get: async function(params){
				return await http.get(this.url + `/${params.page}/${params.pageSize}`, {search: params.keyword || ''});
			}
		},
		options: {
			url: `${config.API_URL}/role/options`,
			name: "获取角色选项",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	dept: {
		create: {
			url: `${config.API_URL}/dept/create`,
			name: "创建部门",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		update: {
			url: `${config.API_URL}/dept/update`,
			name: "更新部门",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		delete: {
			url: `${config.API_URL}/dept/delete`,
			name: "删除部门",
			post: async function(id){
				return await http.post(this.url + `/${id}`);
			}
		},
		list: {
			url: `${config.API_URL}/dept/list`,
			name: "获取部门列表",
			get: async function(params){
				return await http.get(this.url, {search: params.search || ''});
			}
		},
		options: {
			url: `${config.API_URL}/dept/options`,
			name: "获取部门选项",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	user: {
		list: {
			url: `${config.API_URL}/user/list`,
			name: "获取用户列表",
			get: async function(params){
				return await http.get(`${this.url}/${params.groupId||0}/${params.page}/${params.pageSize}`);
			}
		},
		page: {
			url: `${config.API_URL}/user/page`,
			name: "获取用户分页列表",
			get: async function(params){
				return await http.get(`${this.url}/${params.groupId||0}/${params.page}/${params.pageSize}?name=${params.name||''}`);
			}
		},
		create: {
			url: `${config.API_URL}/user/create`,
			name: "创建用户",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		update: {
			url: `${config.API_URL}/user/update`,
			name: "更新用户",
			post: async function(data){
				return await http.post(this.url, data);
			}
		},
		delete: {
			url: `${config.API_URL}/user/delete`,
			name: "删除用户",
			post: async function(id){
				return await http.post(this.url + `/${id}`);
			}
		}
	},
	app: {
		list: {
			url: `${config.API_URL}/system/app/list`,
			name: "应用列表",
			get: async function(){
				return await http.get(this.url);
			}
		}
	},
	log: {
		list: {
			url: `${config.API_URL}/system/log/list`,
			name: "日志列表",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	table: {
		list: {
			url: `${config.API_URL}/system/table/list`,
			name: "表格列管理列表",
			get: async function(params){
				return await http.get(this.url, params);
			}
		},
		info: {
			url: `${config.API_URL}/system/table/info`,
			name: "表格列管理详情",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	},
	tasks: {
		list: {
			url: `${config.API_URL}/system/tasks/list`,
			name: "系统任务管理",
			get: async function(params){
				return await http.get(this.url, params);
			}
		}
	}
}
